<?php
namespace app\tour\controller;
use think\Controller;
use think\Db;
use think\Request;
use think\Session;

class Auth extends Common {
    public function auth(){
        $topmenu = Db::name('tour_auth_rule')->select();
        $topmenu = getTree($topmenu);
        $this->assign('topmenu',$topmenu);
        return view();
    }
    public function authList(){
        $data = Db::name('tour_auth_rule')->select();
        $data = getTree($data);
        $data = array('code'=>0,'msg'=>'','data'=>$data);
        return json($data);
    }

    public function authAdd(){
        $post = Request::instance()->post();
        $result = Db::name('tour_auth_rule')->insert($post['data']);
        if ($result){
            echo '1';
        }else{
            echo '添加失败';
        }
    }

    public function authEdit(){
        $post = Request::instance()->post();
        $result = Db::name('tour_auth_rule')->update($post['data']);
        if($result){
            echo '1';
        }else{
            echo '修改失败';
        }
    }

    public function authDel(){
        $post = Request::instance()->post();
        $result = Db::name('tour_auth_rule')->delete($post['id']);
        if ($result){
            echo '1';
        }else{
            echo '删除失败';
        }
    }


}